//
//  HHAlertViewController.m
//  Flower
//
//  Created by 花花 on 2016/12/12.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHCustomAlertViewController.h"
#import "HHAlertTabViewController.h"
@interface HHCustomAlertViewController ()

@end

@implementation HHCustomAlertViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor =[UIColor lightGrayColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    UIButton *btn =[UIButton buttontitle:@"点我" frame:CGRectMake(0, 0, 100, 100) target:self action:@selector(btnOnClick)];
    btn.center = self.view.center;
    [self.view addSubview:btn];
}

-(void)btnOnClick{
    
    
    __block NSString *text = nil;
    
    NSArray *arr= @[@"123",@"456",@"789",@"666",@"8888",@"333",@"花花同学"];
    
    HHAlertTabViewController *alert =[[HHAlertTabViewController alloc]alertinitWithTitle:@"提示" dataSoreArr:arr setupAlertCellHandler:^(AlertCell *cell, NSIndexPath *indexPath) {
        
        text = cell.nameLabel.text;
        
        
        NSLog(@"%@",cell.nameLabel.text);
    } cancelOnOnlick:^(UIButton *cancenbtn) {
        
        if(text == nil){
        
            [self showHudAutoHideString:@"请选择其中一项"];
            return ;
        }
        
        [self showHudAutoHideString:[NSString stringWithFormat:@"取消--%@",text]];
        NSLog(@"取消---- 点击了%@",text);
        
    } finishOnClick:^(UIButton *finishbtn) {
        
        if(text == nil){
            
            [self showHudAutoHideString:@"请选择其中一项"];
            return ;
        }
        [self showHudAutoHideString:[NSString stringWithFormat:@"确定--%@",text]];
        
    }];
    
    [self.view addSubview: alert.view];
    [self addChildViewController:alert];
}

@end
